<template>
    <el-select v-model="program" style="width: 200px;" clearable placeholder="请选择对应的项目" filterable>
        <el-option v-for="(item, index) in programList" :key="`supplier-item-${index}`" :label="item.project_name"
            :value="item.id" value-key="item.id"></el-option>
    </el-select>
</template>
<script>
export default {
    data() {
        return {
            program: undefined,
            programList: []
        }
    },
    props: {
        value: Number
    },
    watch: {
        value: {
            deep: true,
            immediate: true,
            handler: function () {
                this.program = this.value
            }
        },
        program() {
            this.$emit('input', this.program)
        }
    },
    created() {
        this.getProgram()
    },
    methods: {
        async getProgram() {
            let res = await this.$get({
                url: '/admin/project.Project/index',
            })
            this.programList = res.list
        }
    }
}
</script>
